const { resolve } = require('path')

const mongoose = require(resolve(__dirname, '../db'))

const User = mongoose.model('user', new mongoose.Schema({
  username: {  // 用户名
    type: String,
    required: [true, '用户名不可为空'],
    trim: true,
  },
  password: {  // 密码
    type: String,
    required: [true, '密码不可为空'],
    minlength: [6, '最小长度为6'],
    trim: true
  },
  eMail: {  // 邮箱
    type: String,
    required: false,
    trim: true
  },
  createTime: {  // 注册时间
    type: Number,
    required: false,
    trim: true,
    default: 0
  },
  isBlogger: {  // 博主
    type: Boolean,
    trim: true,
    default: false
  },
  isDel: {
    type: Boolean,
    trim: true,
    default: false
  }
}))

module.exports = {
  User
}